home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume16 / spiff / part02 < prev    next >
Encoding:
Internet Message Format  |  1988-11-10  |  56.7 KB

  1. Subject:  v16i068:  Spiff, find approximate differences in files, Part02/04
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Daniel W Nachbar <daniel@wind.bellcore.com>
  7. Posting-number: Volume 16, Issue 68
  8. Archive-name: spiff/part02
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of archive 2 (of 4)."
  17. # Contents:  Makefile comment.c compare.c line.c line.h output.c
  18. #   spiff.c tol.c visual.c
  19. # Wrapped by rsalz@papaya.bbn.com on Fri Nov 11 13:12:24 1988
  20. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  21. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  22.   echo shar: Will not clobber existing file \"'Makefile'\"
  23. else
  24. echo shar: Extracting \"'Makefile'\" \(4147 characters\)
  25. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  26. X#
  27. X#    START OF LOCAL CONFIGURATION INFORMATION
  28. X#    change the following lines to reflect your local environment
  29. X#
  30. X
  31. X#
  32. X#    name of the directory into which the binary should be installed
  33. X#        used only when you use  'make install'
  34. X#
  35. XINSDIR=/usr/tmp
  36. X
  37. X#
  38. X#    choose one from each of 1) 2) and 3) below
  39. X#
  40. X
  41. X#
  42. X#    1) SELECTION OF OPERATING SYSTEM VARIETY
  43. X#        choose a) b) or c)
  44. X#
  45. X# a) for BSD derivitives, enable the following line
  46. XOSFLAG=
  47. X
  48. X# b) for XENIX systems, enable the following line
  49. X#OSFLAG=-DXENIX
  50. X
  51. X# b) for other A.T. and T. derivitives, enable the following line
  52. X#OSFLAG=-DATT
  53. X
  54. X#
  55. X#     2) SELECTION OF TERMINAL CONTROL LIBRARY
  56. X#        choose either of a) b) or c)
  57. X#
  58. X# a) if you use termcap, enable the following lines
  59. XTFLAG=-DM_TERMCAP
  60. XTLIB=termcap
  61. X
  62. X# b) if you are using terminfo on a XENIX machine, enable the following lines
  63. X#TFLAG=-DM_TERMINFO
  64. X#TLIB=tinfo
  65. X
  66. X# c) if you use terminfo on any other type of machine,
  67. X#    enable the following lines
  68. X#TFLAG=-DM_TERMINFO
  69. X#TLIB=curses
  70. X
  71. X#
  72. X#    3) SELECTION OF WINDOW MANAGER AVAILABILITY
  73. X#
  74. X# if you have the Bellcore's MGR window manager, enable the following lines
  75. X#VISFLAG=-DMGR
  76. X#VISLIB=/usr/public/pkg/mgr/lib/libmgr.a
  77. X#MGRINCDIR=-I/usr/public/pkg/mgr/include
  78. X#MGRINCS=$(MGRINC)/dump.h $(MGRINC)/term.h $(MGRINC)/restart.h $(MGRINC)/window.h
  79. X
  80. X#
  81. X#    END OF LOCAL CONFIGRATION INFORMATION, the rest of this
  82. X#    file may be modified only at great risk
  83. X#        -- caveat hackor
  84. X#
  85. X
  86. X#                        Copyright (c) 1988 Bellcore
  87. X#                            All Rights Reserved
  88. X#       Permission is granted to copy or use this program, EXCEPT that it
  89. X#       may not be sold for profit, the copyright notice must be reproduced
  90. X#       on copies, and credit should be given to Bellcore where it is due.
  91. X#       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  92. X#
  93. X
  94. XCC=cc
  95. XOBJ= spiff.o output.o compare.o float.o strings.o exact.o miller.o parse.o command.o comment.o tol.o line.o token.o floatrep.o misc.o visual.o
  96. XCFILES= spiff.c output.c compare.c float.c strings.c exact.c miller.c parse.c command.c comment.c tol.c line.c floatrep.c token.c misc.c visual.c
  97. XHFILES=misc.h strings.h line.h float.h floatrep.h tol.h command.h comment.h token.h edit.h parse.h compare.h flagdefs.h exact.h miller.h visual.h output.h
  98. XOTHER=README Makefile Sample.1 Sample.2 Sample.3 Sample.4 paper.ms paper.out
  99. XMANPAGE=spiff.1
  100. X
  101. XCFLAGS=-O $(OSFLAG) $(TFLAG) $(VISFLAG)
  102. X
  103. Xdefault: spiff
  104. X
  105. Xspiff: $(OBJ)
  106. X    $(CC) $(CFLAGS) -o spiff $(OBJ) $(VISLIB) -l$(TLIB)
  107. X
  108. Xspiff.o: spiff.c misc.h line.h token.h tol.h command.h edit.h parse.h compare.h flagdefs.h exact.h miller.h visual.h
  109. X
  110. Xvisual.o: visual.c misc.h visual.h $(MGRINCS)
  111. X    $(CC) -c $(CFLAGS) $(MGRINCDIR) visual.c
  112. X
  113. Xmisc.o: misc.c visual.h misc.h
  114. X
  115. Xparse.o:  parse.c misc.h line.h command.h float.h tol.h comment.h parse.h token.h flagdefs.h
  116. X    @echo compiler may report 4 statement not reached warning messages for parse.c
  117. X    $(CC) $(CFLAGS) -c parse.c
  118. X
  119. Xcommand.o: command.c float.h tol.h misc.h
  120. X
  121. Xcomment.o: comment.c misc.h comment.h
  122. X
  123. Xtol.o: tol.c tol.h float.h
  124. X
  125. Xoutput.o: output.c output.h misc.h edit.h flagdefs.h
  126. X
  127. Xcompare.o: compare.c misc.h strings.h float.h tol.h token.h line.h compare.h flagdefs.h
  128. X    @echo compiler may report 1 statement not reached warning message for compare.c
  129. X    $(CC) $(CFLAGS) -c compare.c
  130. X
  131. Xfloat.o: float.c misc.h strings.h float.h floatrep.h
  132. X
  133. Xfloatrep.o: floatrep.c misc.h strings.h floatrep.h
  134. X
  135. Xstrings.o: strings.c  misc.h strings.h
  136. X
  137. Xexact.o: exact.c exact.h misc.h edit.h
  138. X
  139. Xmiller.o: miller.c miller.h misc.h edit.h token.h
  140. X
  141. Xtoken.o: token.c token.h misc.h
  142. X
  143. Xline.o: line.c line.h misc.h
  144. X
  145. Xclean:
  146. X    rm -f *.o
  147. Xclobber: clean
  148. X    rm -f spiff
  149. Xci:
  150. X    ci -l -q  '-m $(CIMSG)' $(CFILES) $(HFILES) $(OTHER) $(MANPAGE)
  151. Xcol:
  152. X    co -l  $(CFILES) $(HFILES) $(OTHER) $(MANPAGE)
  153. Xcirev:
  154. X    ci -l -r$(REV)  '-m $(CIMSG)' $(CFILES) $(HFILES) $(OTHER) $(MANPAGE)
  155. Xcirel:
  156. X    ci -l -q  -sRel  $(CFILES) $(HFILES) $(OTHER) $(MANPAGE)
  157. Xlint: 
  158. X    lint  $(CFLAGS) $(CFILES)
  159. Xcpio:
  160. X    for i in $(CFILES) $(HFILES) $(OTHER) $(MANPAGE); do echo $$i; done | cpio -ocv  > spiff.cpio
  161. X
  162. Xcmd:
  163. X    -$(CMD) $(CFILES) $(HFILES) $(OTHER) $(MANPAGE)
  164. Xinstall:
  165. X    mv spiff $(INSDIR)/bin
  166. X    cp $(MANPAGE) $(INSDIR)/man/man1
  167. X    
  168. END_OF_FILE
  169. if test 4147 -ne `wc -c <'Makefile'`; then
  170.     echo shar: \"'Makefile'\" unpacked with wrong size!
  171. fi
  172. # end of 'Makefile'
  173. fi
  174. if test -f 'comment.c' -a "${1}" != "-c" ; then 
  175.   echo shar: Will not clobber existing file \"'comment.c'\"
  176. else
  177. echo shar: Extracting \"'comment.c'\" \(4943 characters\)
  178. sed "s/^X//" >'comment.c' <<'END_OF_FILE'
  179. X/*                        Copyright (c) 1988 Bellcore
  180. X**                            All Rights Reserved
  181. X**       Permission is granted to copy or use this program, EXCEPT that it
  182. X**       may not be sold for profit, the copyright notice must be reproduced
  183. X**       on copies, and credit should be given to Bellcore where it is due.
  184. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  185. X*/
  186. X
  187. X
  188. X#ifndef lint
  189. Xstatic char rcsid[]= "$Header: comment.c,v 1.1 88/09/15 11:33:58 daniel Rel $";
  190. X#endif
  191. X
  192. X
  193. X#include "misc.h"
  194. X#include "comment.h"
  195. X#include "strings.h"
  196. X
  197. X/*
  198. X**    storage for the comment specifiers that can appear
  199. X**        anywhere on a line
  200. X*/
  201. Xstatic int _W_nextcom = 0;
  202. X_W_comstruct _W_coms[_W_COMMAX];
  203. X
  204. X/*
  205. X**    storage for comment specifiers that are examined only at the
  206. X**        beginning of each line
  207. X*/
  208. Xstatic int _W_nextbol = 0;
  209. X_W_bolstruct _W_bols[_W_BOLMAX];
  210. X
  211. X/*
  212. X**    storage for delimiters of literal strings
  213. X*/
  214. Xstatic int _W_nextlit = 0;
  215. X_W_litstruct _W_lits[_W_LITMAX];
  216. X
  217. X/*
  218. X**    storage for characters to specify beginning and end of line
  219. X**    in the comment and literal commands
  220. X*/
  221. Xchar _W_bolchar = '^';
  222. Xchar _W_eolchar = '$';
  223. X
  224. X
  225. X/*
  226. X**    build up a list of comment delimiters
  227. X*/
  228. Xvoid
  229. XW_addcom(str,nestflag)
  230. Xchar *str;
  231. Xint nestflag;
  232. X{
  233. X    /*
  234. X    **    check for comments that begin at the beginning of line
  235. X    */
  236. X    if (*str ==  _W_bolchar)
  237. X    {
  238. X        if (_W_nextbol >= _W_BOLMAX)
  239. X            Z_fatal("too many beginning of line comment delimiter sets");
  240. X
  241. X        str++;    /*skip the bol char */
  242. X        S_wordcpy(_W_bols[_W_nextbol].begin,str);
  243. X
  244. X        S_nextword(&str);
  245. X
  246. X        if (*str == _W_eolchar)
  247. X        {
  248. X            (void) strcpy(_W_bols[_W_nextbol].end,"\n");
  249. X        }
  250. X        else
  251. X        {
  252. X            S_wordcpy(_W_bols[_W_nextbol].end,str);
  253. X        }
  254. X
  255. X        S_nextword(&str);
  256. X        S_wordcpy(_W_bols[_W_nextbol].escape,str);
  257. X
  258. X        /*
  259. X        **
  260. X        */
  261. X        if (nestflag)
  262. X            Z_complain("begining of line comment won't nest");
  263. X
  264. X        _W_nextbol++;
  265. X    }
  266. X    else
  267. X    {
  268. X        if (_W_nextcom >= _W_COMMAX)
  269. X            Z_fatal("too many comment delimiter sets");
  270. X
  271. X        S_wordcpy(_W_coms[_W_nextcom].begin,str);
  272. X
  273. X        S_nextword(&str);
  274. X
  275. X        if (*str == _W_eolchar)
  276. X        {
  277. X            (void) strcpy(_W_coms[_W_nextbol].end,"\n");
  278. X        }
  279. X        else
  280. X        {
  281. X            S_wordcpy(_W_coms[_W_nextbol].end,str);
  282. X        }
  283. X
  284. X        S_nextword(&str);
  285. X        S_wordcpy(_W_coms[_W_nextcom].escape,str);
  286. X
  287. X        _W_coms[_W_nextcom].nestbit = nestflag;
  288. X
  289. X        _W_nextcom++;
  290. X    }
  291. X    return;
  292. X}
  293. X
  294. X
  295. X/*
  296. X**    clear the comment delimiter storage
  297. X*/
  298. Xvoid
  299. XW_clearcoms()
  300. X{
  301. X    _W_nextcom = 0;
  302. X    _W_nextbol = 0;
  303. X    return;
  304. X}
  305. X
  306. X/*
  307. X**    build up the list of literal delimiters
  308. X*/
  309. Xvoid
  310. XW_addlit(str)
  311. Xchar *str;
  312. X{
  313. X    if (_W_nextlit >= _W_LITMAX)
  314. X        Z_fatal("too many literal delimiter sets");
  315. X
  316. X    S_wordcpy(_W_lits[_W_nextlit].begin,str);
  317. X
  318. X    S_nextword(&str);
  319. X    S_wordcpy(_W_lits[_W_nextlit].end,str);
  320. X
  321. X    S_nextword(&str);
  322. X    S_wordcpy(_W_lits[_W_nextlit].escape,str);
  323. X
  324. X    _W_nextlit++;
  325. X    return;
  326. X}
  327. X
  328. X/*
  329. X**    clear the literal delimiter storage
  330. X*/
  331. Xvoid
  332. XW_clearlits()
  333. X{
  334. X    _W_nextlit = 0;
  335. X    return;
  336. X}
  337. X
  338. X
  339. X
  340. Xstatic _W_bolstruct bol_scratch;
  341. X
  342. Xstatic void
  343. X_W_copybol(to,from)
  344. XW_bol to,from;
  345. X{
  346. X    (void) strcpy(to->begin,from->begin);
  347. X    (void) strcpy(to->end,from->end);
  348. X    (void) strcpy(to->escape,from->escape);
  349. X}
  350. X
  351. XW_bol
  352. XW_isbol(str)
  353. Xchar *str;
  354. X{
  355. X    int i;
  356. X
  357. X    for(i=0;i<_W_nextbol;i++)
  358. X    {
  359. X        if(!S_wordcmp(str,_W_bols[i].begin))
  360. X        {
  361. X            _W_copybol(&bol_scratch,&_W_bols[i]);
  362. X            return(&bol_scratch);
  363. X        }
  364. X    }
  365. X    return(W_BOLNULL);
  366. X}
  367. X
  368. XW_is_bol(ptr)
  369. XW_bol ptr;
  370. X{
  371. X    int i;
  372. X
  373. X    for(i=0;i<_W_nextbol;i++)
  374. X    {
  375. X        if(!S_wordcmp(ptr->begin,_W_bols[i].begin) &&
  376. X            !S_wordcmp(ptr->end,_W_bols[i].end) &&
  377. X            !S_wordcmp(ptr->escape,_W_bols[i].escape))
  378. X        {
  379. X            return(1);
  380. X        }
  381. X
  382. X    }
  383. X    return(0);
  384. X}
  385. X
  386. X
  387. Xstatic _W_litstruct lit_scratch;
  388. X
  389. Xstatic void
  390. X_W_copylit(to,from)
  391. XW_lit to,from;
  392. X{
  393. X    (void) strcpy(to->begin,from->begin);
  394. X    (void) strcpy(to->end,from->end);
  395. X    (void) strcpy(to->escape,from->escape);
  396. X}
  397. X
  398. XW_lit
  399. XW_islit(str)
  400. Xchar *str;
  401. X{
  402. X    int i;
  403. X
  404. X    for(i=0;i<_W_nextlit;i++)
  405. X    {
  406. X        if(!S_wordcmp(str,_W_lits[i].begin))
  407. X        {
  408. X            _W_copylit(&lit_scratch,&_W_lits[i]);
  409. X            return(&lit_scratch);
  410. X        }
  411. X    }
  412. X    return(W_LITNULL);
  413. X}
  414. X
  415. XW_is_lit(ptr)
  416. XW_lit ptr;
  417. X{
  418. X    int i;
  419. X
  420. X    for(i=0;i<_W_nextlit;i++)
  421. X    {
  422. X        if(!S_wordcmp(ptr->begin,_W_lits[i].begin) &&
  423. X            !S_wordcmp(ptr->end,_W_lits[i].end) &&
  424. X            !S_wordcmp(ptr->escape,_W_lits[i].escape))
  425. X        {
  426. X            return(1);
  427. X        }
  428. X
  429. X    }
  430. X    return(0);
  431. X}
  432. X
  433. Xstatic _W_comstruct com_scratch;
  434. X
  435. Xstatic void
  436. X_W_copycom(to,from)
  437. XW_com to,from;
  438. X{
  439. X    (void) strcpy(to->begin,from->begin);
  440. X    (void) strcpy(to->end,from->end);
  441. X    (void) strcpy(to->escape,from->escape);
  442. X    to->nestbit = from->nestbit;
  443. X}
  444. X
  445. XW_com
  446. XW_iscom(str)
  447. Xchar *str;
  448. X{
  449. X    int i;
  450. X
  451. X    for(i=0;i<_W_nextcom;i++)
  452. X    {
  453. X        if(!S_wordcmp(str,_W_coms[i].begin))
  454. X        {
  455. X            _W_copycom(&com_scratch,&_W_coms[i]);
  456. X            return(&com_scratch);
  457. X        }
  458. X    }
  459. X    return(W_COMNULL);
  460. X}
  461. X
  462. XW_is_com(ptr)
  463. XW_com ptr;
  464. X{
  465. X    int i;
  466. X
  467. X    for(i=0;i<_W_nextcom;i++)
  468. X    {
  469. X        if(!S_wordcmp(ptr->begin,_W_coms[i].begin) &&
  470. X            !S_wordcmp(ptr->end,_W_coms[i].end) &&
  471. X            !S_wordcmp(ptr->escape,_W_coms[i].escape) &&
  472. X            ptr->nestbit == _W_coms[i].nestbit)
  473. X        {
  474. X            return(1);
  475. X        }
  476. X
  477. X    }
  478. X    return(0);
  479. X}
  480. X
  481. XW_is_nesting(ptr)
  482. XW_com ptr;
  483. X{
  484. X    return(ptr->nestbit);
  485. X}
  486. END_OF_FILE
  487. if test 4943 -ne `wc -c <'comment.c'`; then
  488.     echo shar: \"'comment.c'\" unpacked with wrong size!
  489. fi
  490. # end of 'comment.c'
  491. fi
  492. if test -f 'compare.c' -a "${1}" != "-c" ; then 
  493.   echo shar: Will not clobber existing file \"'compare.c'\"
  494. else
  495. echo shar: Extracting \"'compare.c'\" \(4024 characters\)
  496. sed "s/^X//" >'compare.c' <<'END_OF_FILE'
  497. X/*                        Copyright (c) 1988 Bellcore
  498. X**                            All Rights Reserved
  499. X**       Permission is granted to copy or use this program, EXCEPT that it
  500. X**       may not be sold for profit, the copyright notice must be reproduced
  501. X**       on copies, and credit should be given to Bellcore where it is due.
  502. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  503. X*/
  504. X
  505. X
  506. X#ifndef lint
  507. Xstatic char rcsid[]= "$Header: compare.c,v 1.1 88/09/15 11:33:53 daniel Rel $";
  508. X#endif
  509. X
  510. X#include "misc.h"
  511. X#include "flagdefs.h"
  512. X#include "tol.h"
  513. X#include "token.h"
  514. X#include "line.h"
  515. X#include "float.h"
  516. X#include "compare.h"
  517. X
  518. X#include <ctype.h>
  519. X
  520. XX_com(a,b,flags)
  521. Xint a,b,flags;
  522. X{
  523. X    K_token atmp,btmp;
  524. X
  525. X    atmp = K_gettoken(0,a);
  526. X    btmp = K_gettoken(1,b);
  527. X    if(flags & U_BYTE_COMPARE)
  528. X    {
  529. X        return(_X_strcmp(K_gettext(atmp),K_gettext(btmp),flags));
  530. X    }
  531. X    else
  532. X    {
  533. X        return(_X_cmptokens(atmp,btmp,flags));
  534. X    }
  535. X#ifndef lint 
  536. X    Z_fatal("this line should never be reached in com");
  537. X    return(-1);    /* Z_fatal never returns, but i need a this line
  538. X                here to stop lint from complaining */
  539. X#endif
  540. X}
  541. X
  542. X/*
  543. X**    same as strcmp() except that case can be optionally ignored
  544. X*/
  545. Xstatic int
  546. X_X_strcmp(s1,s2,flags)
  547. Xchar *s1,*s2;
  548. Xint flags;
  549. X{
  550. X    if (flags & U_NO_CASE)
  551. X    {
  552. X        
  553. X        for (;('\0' != s1) && ('\0' !=  *s2);s1++,s2++)
  554. X        {
  555. X            if(isalpha(*s1) && isalpha(*s2))
  556. X            {
  557. X                if(tolower(*s1) != tolower(*s2))
  558. X                {
  559. X                    return(1);
  560. X                }
  561. X            }
  562. X            else
  563. X            {
  564. X                if(*s1!=*s2)
  565. X                {
  566. X                    return(1);
  567. X                }
  568. X            }
  569. X        }
  570. X        return(*s1 != *s2);
  571. X    }
  572. X    else
  573. X    {
  574. X        return(strcmp(s1,s2));
  575. X    }
  576. X}
  577. X
  578. X
  579. X/*
  580. X**    routine to compare two tokens
  581. X*/
  582. Xstatic int
  583. X_X_cmptokens(p1,p2,flags)
  584. XK_token p1, p2;
  585. Xint flags;
  586. X{
  587. X    if (K_gettype(p1) !=  K_gettype(p2))
  588. X    {
  589. X        return(1);
  590. X    }
  591. X
  592. X    switch (K_gettype(p1))
  593. X    {
  594. X        case K_LIT:
  595. X            return(_X_strcmp(K_gettext(p1),K_gettext(p2),flags));
  596. X        case K_FLO_NUM:
  597. X            return(_X_floatdiff(K_getfloat(p1),
  598. X                       K_getfloat(p2),
  599. X                       T_picktol(K_gettol(p1),
  600. X                             K_gettol(p2))));
  601. X        default:
  602. X            Z_fatal("fell off switch in _X_cmptokens");
  603. X            return(-1);    /* Z_fatal never returns, but i need a this line
  604. X                        here to stop lint from complaining */
  605. X    }
  606. X
  607. X}
  608. X
  609. X/*
  610. X**    compare two F_floats using a tolerance
  611. X*/
  612. Xstatic int
  613. X_X_floatdiff(p1,p2,the_tol)
  614. XF_float p1,p2;
  615. XT_tol the_tol;
  616. X{
  617. X    F_float diff, float_tmp;
  618. X    T_tol tol_tmp;
  619. X
  620. X    /*
  621. X    **     check for null tolerance list
  622. X    */
  623. X    if (T_isnull(the_tol))
  624. X    {
  625. X        Z_fatal("_X_floatdiff called with a null tolerance");
  626. X    }
  627. X
  628. X    /*
  629. X    **    look for an easy answer. i.e -- check
  630. X    **        to see if any of the tolerances are of type T_IGNORE
  631. X    **        or if the numbers are too small to exceed an absolute
  632. X    **        tolerance.
  633. X    **        if so, return immediately
  634. X    */
  635. X    for(tol_tmp=the_tol; !(T_isnull(tol_tmp)) ;tol_tmp=T_getnext(tol_tmp))
  636. X    {
  637. X        if ((T_IGNORE == T_gettype(tol_tmp)) || 
  638. X            /*
  639. X            **    take a look at the exponents before you bother
  640. X            **    with the mantissas
  641. X            */
  642. X            ((T_ABSOLUTE == T_gettype(tol_tmp))
  643. X                   && !F_zerofloat(T_getfloat(tol_tmp))
  644. X                   && (F_getexp(p1) <
  645. X                    F_getexp(T_getfloat(tol_tmp))-1)
  646. X                   && (F_getexp(p2) <
  647. X                    F_getexp(T_getfloat(tol_tmp))-1)))
  648. X        {
  649. X                return(0);
  650. X        }
  651. X    }
  652. X
  653. X    
  654. X    /*
  655. X    **    ok, we're going to have to do some arithmetic, so
  656. X    **        first find the magnitude of the difference
  657. X    */
  658. X    if (F_getsign(p1) != F_getsign(p2))
  659. X    {
  660. X        diff = F_floatmagadd(p1,p2);
  661. X    }
  662. X    else
  663. X    {
  664. X        diff = F_floatsub(p1,p2);
  665. X    }
  666. X
  667. X    /*
  668. X    **    now check to see if the difference exceeds any tolerance
  669. X    */
  670. X    for(tol_tmp=the_tol; !(T_isnull(tol_tmp)) ;tol_tmp=T_getnext(tol_tmp))
  671. X    {
  672. X        float_tmp = T_getfloat(tol_tmp);
  673. X
  674. X        if (T_gettype(tol_tmp) == T_ABSOLUTE)
  675. X        {
  676. X            /* do nothing */
  677. X        }
  678. X        else if (T_gettype(tol_tmp) == T_RELATIVE)
  679. X        {
  680. X            if (F_floatcmp(p1,p2) > 0)
  681. X            {
  682. X                float_tmp = F_floatmul(p1, float_tmp);
  683. X            }
  684. X            else
  685. X            {
  686. X                float_tmp = F_floatmul(p2, float_tmp);
  687. X            }
  688. X        }
  689. X        else
  690. X        {
  691. X            Z_fatal("bad value for type of tolerance in floatdiff");
  692. X        }
  693. X        /*
  694. X        **    if we pass this tolerance, then we're done
  695. X        */
  696. X        if (F_floatcmp(diff,float_tmp) <= 0)
  697. X        {
  698. X            return(0);
  699. X        }
  700. X    }
  701. X    /*
  702. X    **    all of the tolerances were exceeded
  703. X    */
  704. X    return(1);
  705. X}
  706. END_OF_FILE
  707. if test 4024 -ne `wc -c <'compare.c'`; then
  708.     echo shar: \"'compare.c'\" unpacked with wrong size!
  709. fi
  710. # end of 'compare.c'
  711. fi
  712. if test -f 'line.c' -a "${1}" != "-c" ; then 
  713.   echo shar: Will not clobber existing file \"'line.c'\"
  714. else
  715. echo shar: Extracting \"'line.c'\" \(3570 characters\)
  716. sed "s/^X//" >'line.c' <<'END_OF_FILE'
  717. X/*                        Copyright (c) 1988 Bellcore
  718. X**                            All Rights Reserved
  719. X**       Permission is granted to copy or use this program, EXCEPT that it
  720. X**       may not be sold for profit, the copyright notice must be reproduced
  721. X**       on copies, and credit should be given to Bellcore where it is due.
  722. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  723. X*/
  724. X
  725. X
  726. X#ifndef lint
  727. Xstatic char rcsid[]= "$Header: line.c,v 1.1 88/09/15 11:34:00 daniel Rel $";
  728. X#endif
  729. X
  730. X#include <stdio.h>
  731. X#include "misc.h"
  732. X#include "token.h"
  733. X#include "line.h"
  734. X
  735. Xchar *_L_al[_L_MAXLINES];  /* storage for lines */
  736. Xchar *_L_bl[_L_MAXLINES];
  737. X
  738. Xint   _L_ai[_L_MAXLINES];  /* index from token line number to first token */
  739. Xint   _L_bi[_L_MAXLINES];
  740. X
  741. Xint   _L_ac[_L_MAXLINES];  /* count of tokens on this token line */
  742. Xint   _L_bc[_L_MAXLINES];
  743. X
  744. Xint   _L_arlm;        /* count of real lines in the file */
  745. Xint   _L_brlm;
  746. X
  747. Xint   _L_aclm;        /* count of content lines in the file */
  748. Xint   _L_bclm;
  749. X
  750. Xint   _L_atlm;        /* count of token lines in the file */
  751. Xint   _L_btlm;
  752. X
  753. Xint   _L_aclindex[_L_MAXLINES]; /* mapping from content lines to real lines*/
  754. Xint   _L_bclindex[_L_MAXLINES]; 
  755. X
  756. Xint   _L_atlindex[_L_MAXLINES]; /*mapping from token lines to content lines */
  757. Xint   _L_btlindex[_L_MAXLINES];
  758. X
  759. X
  760. Xstatic void
  761. X_L_setrline(file,X,str)
  762. Xint file;
  763. Xint X;
  764. Xchar *str;
  765. X{
  766. X    if (file)
  767. X    {
  768. X        S_savestr(&_L_bl[X],str);
  769. X    }
  770. X    else
  771. X    {
  772. X        S_savestr(&_L_al[X],str);
  773. X    }
  774. X    return;
  775. X}
  776. X/*
  777. X**    returns 1 if we reached the end of file
  778. X**    returns 0 if there is more to do
  779. X**
  780. X**    stores data and sets maximum counts
  781. X*/
  782. XL_init_file(fnumber,fname)
  783. Xint fnumber;
  784. Xchar *fname;
  785. X{
  786. X    extern char *fgets();
  787. X    FILE *fp;
  788. X    static char buf[Z_LINELEN+2];    /* +2 is to leave room for us to add
  789. X                        a newline if we need to */
  790. X    int ret_val = 1;
  791. X    int tmplen;
  792. X
  793. X    if ((fp = fopen(fname,"r")) == (FILE*) NULL)
  794. X    {
  795. X        (void) sprintf(Z_err_buf, "Cannot open file %s.\n",fname);
  796. X        Z_fatal(Z_err_buf);
  797. X    }
  798. X
  799. X    /*
  800. X    **    clear the line count
  801. X    */
  802. X    _L_setrlmx(fnumber,0);
  803. X
  804. X    /*
  805. X    **    read in the entire file
  806. X    */
  807. X    while (fgets(buf,Z_LINELEN+1,fp) != (char *) NULL)
  808. X    {
  809. X        tmplen = strlen(buf);
  810. X        if (tmplen <= 0)
  811. X        {
  812. X            (void) sprintf(Z_err_buf,
  813. X              "fatal error -- got 0 length line %d in file %s\n",
  814. X                L_getrlmax(fnumber)+1,
  815. X                fname);
  816. X            Z_fatal(Z_err_buf);
  817. X        }
  818. X        else if (tmplen > Z_LINELEN)
  819. X        {
  820. X            (void) sprintf(Z_err_buf,
  821. X  "got fatally long line %d in file %s length is %d, must be a bug\n",
  822. X                L_getrlmax(fnumber)+1,
  823. X                fname,tmplen);
  824. X            Z_fatal(Z_err_buf);
  825. X        }
  826. X        /*
  827. X        **    look for newline as last character
  828. X        */
  829. X        if ('\n' != buf[tmplen-1])
  830. X        {
  831. X            /*
  832. X            **    did we run out room in the buffer?
  833. X            */
  834. X            if (tmplen == Z_LINELEN)
  835. X            {
  836. X            (void) sprintf(Z_err_buf,
  837. X    "line %d too long in file %s, newline added after %d characters\n",
  838. X                L_getrlmax(fnumber)+1,
  839. X                fname,Z_LINELEN);
  840. X            Z_complain(Z_err_buf);
  841. X            }
  842. X            else
  843. X            {
  844. X            (void) sprintf(Z_err_buf,
  845. X    "didn't find a newline at end of line %d in file %s, added one\n",
  846. X                L_getrlmax(fnumber)+1,
  847. X                fname);
  848. X            Z_complain(Z_err_buf);
  849. X            }
  850. X
  851. X            buf[tmplen] = '\n';
  852. X            buf[tmplen+1] = '\0';
  853. X        }
  854. X
  855. X        _L_setrline(fnumber,L_getrlmax(fnumber),buf);
  856. X
  857. X        if (L_getrlmax(fnumber) >= _L_MAXLINES-1)
  858. X        {
  859. X            (void) sprintf(Z_err_buf,
  860. X    "warning -- ran out of space reading %s, truncated to %d lines\n",
  861. X                fname,_L_MAXLINES);
  862. X            Z_complain(Z_err_buf);
  863. X            ret_val= 0;
  864. X            break;
  865. X        }
  866. X        else
  867. X        {
  868. X            /*
  869. X            **    increment the line count
  870. X            */
  871. X            _L_incrlmx(fnumber);
  872. X        }
  873. X
  874. X    }
  875. X
  876. X    (void) fclose(fp);
  877. X    /*
  878. X    **    reset line numbers
  879. X    */
  880. X    L_setclmax(fnumber,0);
  881. X    L_settlmax(fnumber,0);
  882. X
  883. X    return(ret_val);
  884. X}
  885. X
  886. END_OF_FILE
  887. if test 3570 -ne `wc -c <'line.c'`; then
  888.     echo shar: \"'line.c'\" unpacked with wrong size!
  889. fi
  890. # end of 'line.c'
  891. fi
  892. if test -f 'line.h' -a "${1}" != "-c" ; then 
  893.   echo shar: Will not clobber existing file \"'line.h'\"
  894. else
  895. echo shar: Extracting \"'line.h'\" \(3621 characters\)
  896. sed "s/^X//" >'line.h' <<'END_OF_FILE'
  897. X/*                        Copyright (c) 1988 Bellcore
  898. X**                            All Rights Reserved
  899. X**       Permission is granted to copy or use this program, EXCEPT that it
  900. X**       may not be sold for profit, the copyright notice must be reproduced
  901. X**       on copies, and credit should be given to Bellcore where it is due.
  902. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  903. X*/
  904. X
  905. X
  906. X#ifndef L_INCLUDED
  907. X
  908. X#define _L_MAXLINES    10000
  909. X
  910. X/*
  911. X**    oh god, is this an ugly implementation.
  912. X**    I really should have a two dimensional array of structures
  913. X**        the history of the current arrangement is too long
  914. X**        and ugly to record here.
  915. X**        Someday when I have too much time on my hands . . .
  916. X*/
  917. X
  918. Xextern char *_L_al[];    /* storage for text in first file */
  919. Xextern char *_L_bl[];    /* storage for text in second file */
  920. X
  921. Xextern int _L_ai[];    /* pointer from token line to first token */
  922. Xextern int _L_bi[];
  923. X
  924. Xextern int _L_ac[];    /* number of tokens on a given token line */
  925. Xextern int _L_bc[];
  926. X
  927. Xextern int _L_aclindex[]; /* mapping from content lines to real lines */
  928. Xextern int _L_bclindex[];
  929. X
  930. Xextern int _L_atlindex[]; /* mapping from lines with tokens to content lines */
  931. Xextern int _L_btlindex[];
  932. X
  933. Xextern int _L_arlm;    /* count of real lines */
  934. Xextern int _L_brlm;
  935. X
  936. Xextern int _L_aclm;    /* count of content lines */
  937. Xextern int _L_bclm;
  938. X
  939. Xextern int _L_atlm;    /* count of lines with tokens */
  940. Xextern int _L_btlm;
  941. X
  942. X/*
  943. X**    routines to set up mappings from token lines to content lines
  944. X**      and from content lines to real lines
  945. X*/
  946. X#define L_setclindex(file,content,real) (file?(_L_bclindex[content]=real):\
  947. X                         (_L_aclindex[content]=real))
  948. X
  949. X#define L_settlindex(file,token,content) (file?(_L_btlindex[token]=content):\
  950. X                          (_L_atlindex[token]=content))
  951. X/*
  952. X**    get line number X from file
  953. X*/
  954. X#define L_getrline(file, X)     (file?(_L_bl[X]):(_L_al[X]))
  955. X#define L_getcline(file, X)     (file?(_L_bl[_L_bclindex[X]]):\
  956. X                       (_L_al[_L_aclindex[X]]))
  957. X#define L_gettline(file, X)     (file?(_L_bl[_L_bclindex[_L_btlindex[X]]]):\
  958. X                       (_L_al[_L_aclindex[_L_atlindex[X]]]))
  959. X
  960. X#define L_cl2rl(file, X)     (file?(_L_bclindex[X]):\
  961. X                       (_L_aclindex[X]))
  962. X#define L_tl2cl(file, X)     (file?(_L_btlindex[X]):\
  963. X                       (_L_atlindex[X]))
  964. X#define L_tl2rl(file, X)     (file?(_L_bclindex[_L_btlindex[X]]):\
  965. X                       (_L_aclindex[_L_atlindex[X]]))
  966. X
  967. X/*
  968. X**    get number of first token on line X of the file
  969. X*/
  970. X#define L_getindex(file,X)    (file?(_L_bi[X]):(_L_ai[X]))
  971. X
  972. X/*
  973. X**    get count of number of tokens on line X of first file
  974. X*/
  975. X#define L_getcount(file,X)    (file?(_L_bc[X]):(_L_ac[X]))
  976. X
  977. X/*
  978. X**    save number of first token for line X of file
  979. X*/
  980. X#define L_setindex(file,index,value)    (file?(_L_bi[index]=value):(_L_ai[index]=value))
  981. X/*
  982. X**    save count of tokens on line X of file
  983. X*/
  984. X#define L_setcount(file,index,value)    (file?(_L_bc[index]=value):(_L_ac[index]=value))
  985. X#define    L_inccount(file,index)        (file?(_L_bc[index]++):(_L_ac[index]++))
  986. X
  987. X/*
  988. X**    retrieve line and token counts
  989. X*/
  990. X#define L_getrlmax(file)    (file?_L_brlm:_L_arlm)
  991. X#define L_getclmax(file)    (file?_L_bclm:_L_aclm)
  992. X#define L_gettlmax(file)    (file?_L_btlm:_L_atlm)
  993. X
  994. X/*
  995. X**    set line and token counts
  996. X*/
  997. X#define _L_setrlmx(file,value)    (file?(_L_brlm=(value)):(_L_arlm=(value)))
  998. X#define L_setclmax(file,value)    (file?(_L_bclm=(value)):(_L_aclm=(value)))
  999. X#define L_settlmax(file,value)    (file?(_L_btlm=(value)):(_L_atlm=(value)))
  1000. X
  1001. X/*
  1002. X**    increment line and token counts
  1003. X*/
  1004. X#define    _L_incrlmx(file)        (file?(_L_brlm++):(_L_arlm++))
  1005. X#define    L_incclmax(file)        (file?(_L_bclm++):(_L_aclm++))
  1006. X#define    L_inctlmax(file)        (file?(_L_btlm++):(_L_atlm++))
  1007. X
  1008. X#define L_INCLUDED
  1009. X#endif
  1010. END_OF_FILE
  1011. if test 3621 -ne `wc -c <'line.h'`; then
  1012.     echo shar: \"'line.h'\" unpacked with wrong size!
  1013. fi
  1014. # end of 'line.h'
  1015. fi
  1016. if test -f 'output.c' -a "${1}" != "-c" ; then 
  1017.   echo shar: Will not clobber existing file \"'output.c'\"
  1018. else
  1019. echo shar: Extracting \"'output.c'\" \(10536 characters\)
  1020. sed "s/^X//" >'output.c' <<'END_OF_FILE'
  1021. X/*                        Copyright (c) 1988 Bellcore
  1022. X**                            All Rights Reserved
  1023. X**       Permission is granted to copy or use this program, EXCEPT that it
  1024. X**       may not be sold for profit, the copyright notice must be reproduced
  1025. X**       on copies, and credit should be given to Bellcore where it is due.
  1026. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  1027. X*/
  1028. X
  1029. X
  1030. X#ifndef lint
  1031. Xstatic char rcsid[]= "$Header: output.c,v 1.1 88/09/15 11:33:52 daniel Rel $";
  1032. X#endif
  1033. X
  1034. X#include <stdio.h>
  1035. X
  1036. X#ifdef M_TERMINFO
  1037. X#include <curses.h>
  1038. X#include <term.h>
  1039. X#endif
  1040. X
  1041. X#ifdef M_TERMCAP
  1042. X#ifdef XENIX
  1043. X#include <tcap.h>
  1044. X#endif
  1045. X#endif
  1046. X
  1047. X#include "misc.h"
  1048. X#include "flagdefs.h"
  1049. X#include "edit.h"
  1050. X#include "line.h"
  1051. X#include "token.h"
  1052. X
  1053. Xstatic int _O_need_init = 1;
  1054. Xstatic int _O_st_ok = 0;
  1055. Xstatic int _O_doing_ul = 0;
  1056. Xstatic    char *_O_st_tmp;
  1057. X#ifdef M_TERMCAP
  1058. Xstatic    char _O_startline[Z_WORDLEN];
  1059. Xstatic    char _O_endline[Z_WORDLEN];
  1060. X#endif
  1061. X
  1062. Xstatic void
  1063. X_O_st_init()
  1064. X{
  1065. X    char termn[Z_WORDLEN];
  1066. X#ifdef M_TERMCAP
  1067. X    static    char entry[1024];
  1068. X#endif
  1069. X
  1070. X    /*
  1071. X    **    see if standard out is a terminal
  1072. X    */
  1073. X    if (!isatty(1))
  1074. X    {
  1075. X        _O_need_init = 0;
  1076. X        _O_st_ok = 0;
  1077. X        return;
  1078. X    }
  1079. X
  1080. X    if (NULL == (_O_st_tmp = (char*) getenv("TERM")))
  1081. X    {
  1082. X        Z_complain("can't find TERM entry in environment\n");
  1083. X        _O_need_init = 0;
  1084. X        _O_st_ok = 0;
  1085. X        return;
  1086. X    }
  1087. X    (void) strcpy(termn,_O_st_tmp);
  1088. X
  1089. X#ifdef M_TERMCAP
  1090. X    if (1 != tgetent(entry,termn))
  1091. X    {
  1092. X        Z_complain("can't get TERMCAP info for terminal\n");
  1093. X        _O_need_init = 0;
  1094. X        _O_st_ok = 0;
  1095. X        return;
  1096. X    }
  1097. X
  1098. X    _O_st_tmp = _O_startline;
  1099. X    _O_startline[0] = '\0';
  1100. X    tgetstr("so",&_O_st_tmp);
  1101. X
  1102. X    _O_st_tmp = _O_endline;
  1103. X    _O_endline[0] = '\0';
  1104. X    tgetstr("se",&_O_st_tmp);
  1105. X
  1106. X    _O_st_ok = (strlen(_O_startline) > 0) && (strlen(_O_endline) > 0);
  1107. X#endif
  1108. X
  1109. X#ifdef M_TERMINFO
  1110. X    setupterm(termn,1,&_O_st_ok);
  1111. X#endif
  1112. X    _O_need_init = 0;
  1113. X}
  1114. X
  1115. Xvoid
  1116. XO_cleanup()
  1117. X{
  1118. X    /*
  1119. X    **    this probably isn't necessary, but in the
  1120. X    **    name of compeleteness.
  1121. X    */
  1122. X#ifdef M_TERMINFO
  1123. X    resetterm();
  1124. X#endif
  1125. X}
  1126. X
  1127. Xstatic void
  1128. X_O_start_standout()
  1129. X{
  1130. X    if (_O_need_init)
  1131. X    {
  1132. X        _O_st_init();
  1133. X    }
  1134. X    if (_O_st_ok)
  1135. X    {
  1136. X#ifdef M_TERMCAP
  1137. X        (void) printf("%s",_O_startline);
  1138. X#endif 
  1139. X#ifdef M_TERMINFO
  1140. X        vidattr(A_STANDOUT);
  1141. X#endif
  1142. X    }
  1143. X    else
  1144. X    {
  1145. X        _O_doing_ul = 1;
  1146. X    }
  1147. X}
  1148. X
  1149. Xstatic void
  1150. X_O_end_standout()
  1151. X{
  1152. X    if (_O_need_init)
  1153. X    {
  1154. X        _O_st_init();
  1155. X    }
  1156. X    if (_O_st_ok)
  1157. X    {
  1158. X#ifdef M_TERMCAP
  1159. X        (void) printf("%s",_O_endline);
  1160. X#endif 
  1161. X#ifdef M_TERMINFO
  1162. X        vidattr(0);
  1163. X#endif
  1164. X    }
  1165. X    else
  1166. X    {
  1167. X        _O_doing_ul = 0;
  1168. X    }
  1169. X}
  1170. X
  1171. Xstatic void
  1172. X_O_pchars(line,start,end)
  1173. Xchar *line;
  1174. Xint start,end;
  1175. X{
  1176. X    int cnt;
  1177. X
  1178. X    for(cnt=start;cnt < end; cnt++)
  1179. X    {
  1180. X        if (_O_doing_ul)
  1181. X        {
  1182. X            (void) putchar('_');
  1183. X            (void) putchar('\b');
  1184. X        }
  1185. X        (void) putchar(line[cnt]);
  1186. X    }
  1187. X}
  1188. X
  1189. X
  1190. X/*
  1191. X**    convert a 0 origin token number to a 1 orgin token
  1192. X**        number or 1 origin line number as appropriate
  1193. X*/
  1194. Xstatic
  1195. X_O_con_line(numb,flags,filenum)
  1196. Xint numb, flags,filenum;
  1197. X{
  1198. X    if (flags & U_TOKENS)
  1199. X    {
  1200. X        return(numb+1);
  1201. X    }
  1202. X    else
  1203. X    {
  1204. X        /*
  1205. X        **     check to make sure that this is a real
  1206. X        **    line number. if not, then return 0
  1207. X        **    on rare occasions, (i.e. insertion/deletion
  1208. X        **    of the first token in a file) we'll get
  1209. X        **    line numbers of -1.  the usual look-up technique
  1210. X        **    won't work since we have no lines before than 0.
  1211. X        */
  1212. X        if (numb < 0)
  1213. X            return(0);
  1214. X        /*
  1215. X        **    look up the line number the token and then
  1216. X        **    add 1 to make line number 1 origin
  1217. X        */
  1218. X        return(L_tl2cl(filenum,numb)+1);
  1219. X    }
  1220. X}
  1221. X
  1222. Xstatic char *
  1223. X_O_convert(ptr)
  1224. Xchar *ptr;
  1225. X{
  1226. X    static char spacetext[Z_WORDLEN];
  1227. X
  1228. X    if (1 == strlen(ptr))
  1229. X    {
  1230. X        switch (*ptr)
  1231. X        {
  1232. X            default:
  1233. X                break;
  1234. X            case '\n' :
  1235. X                (void) strcpy(spacetext,"<NEWLINE>");
  1236. X                return(spacetext);
  1237. X            case '\t' :
  1238. X                (void) strcpy(spacetext,"<TAB>");
  1239. X                return(spacetext);
  1240. X            case ' ' :
  1241. X                (void) strcpy(spacetext,"<SPACE>");
  1242. X                return(spacetext);
  1243. X        }
  1244. X                
  1245. X    }
  1246. X    return(ptr);
  1247. X}
  1248. X
  1249. Xstatic char*
  1250. X_O_get_text(file,index,flags)
  1251. Xint file,index,flags;
  1252. X{
  1253. X    static char buf[Z_LINELEN*2];    /* leave lots of room for both
  1254. X                        the token text and the
  1255. X                        chatter that preceeds it */
  1256. X    char *text;
  1257. X    K_token tmp;
  1258. X
  1259. X    if (flags & U_TOKENS)
  1260. X    {
  1261. X        tmp = K_gettoken(file,index);
  1262. X        text = _O_convert(K_gettext(tmp));
  1263. X        (void) sprintf(buf,"%s -- line %d, character %d\n",
  1264. X                text,
  1265. X                /*
  1266. X                **    add 1 to make output start at line 1 
  1267. X                **    and character numbers start at 1
  1268. X                */
  1269. X                L_tl2cl(file,K_getline(tmp))+1,
  1270. X                K_getpos(tmp)+1);
  1271. X        return(buf);
  1272. X    }
  1273. X    else
  1274. X    {
  1275. X        return(L_gettline(file,index));
  1276. X    }
  1277. X}
  1278. X#define    _O_APP        1
  1279. X#define _O_DEL        2
  1280. X#define _O_CHA        3
  1281. X#define _O_TYPE_E    4
  1282. X
  1283. Xstatic void
  1284. X_O_do_lines(start,end,file)
  1285. Xint start,end,file;
  1286. X{
  1287. X    int cnt;
  1288. X    int lastline = -1;
  1289. X    int nextline;
  1290. X    K_token nexttoken;
  1291. X    for (cnt=start;cnt <= end; cnt++)
  1292. X    {
  1293. X        nexttoken = K_get_token(file,cnt);
  1294. X        nextline = K_getline(nexttoken);
  1295. X        if (lastline != nextline)
  1296. X        {
  1297. X            int lastone,lastchar;
  1298. X            K_token lasttok;
  1299. X            char linetext[Z_LINELEN+1];    /* leave room for
  1300. X                               terminator */
  1301. X            if (0 == file)
  1302. X            {
  1303. X                (void) printf("< ");
  1304. X            }
  1305. X            else
  1306. X            {
  1307. X                (void) printf("> ");
  1308. X            }
  1309. X
  1310. X            /*
  1311. X            **    put loop here if you want to print
  1312. X            **    out any intervening lines that don't
  1313. X            **    have any tokens on them
  1314. X            */
  1315. X
  1316. X            /*
  1317. X            **    following line is necessary because
  1318. X            **    L_gettline is a macro, and can't be passed
  1319. X            */
  1320. X            (void) strcpy(linetext,L_gettline(file,nextline));
  1321. X            _O_pchars(linetext,0,K_getpos(nexttoken));
  1322. X            _O_start_standout();
  1323. X            /*
  1324. X            **     look for last token on this line to be
  1325. X            **    highlighted
  1326. X            */
  1327. X            for ( lastone=cnt,lasttok = K_get_token(file,lastone);
  1328. X                  (lastone<=end)&&(nextline == K_getline(lasttok));
  1329. X                lastone++,lasttok = K_get_token(file,lastone))
  1330. X            {
  1331. X            }
  1332. X            lastone--;
  1333. X            lasttok = K_get_token(file,lastone);
  1334. X            lastchar = K_getpos(lasttok)
  1335. X                    + strlen(K_gettext(lasttok));
  1336. X            _O_pchars(linetext,K_getpos(nexttoken),lastchar);
  1337. X            _O_end_standout();
  1338. X            _O_pchars(linetext,lastchar,strlen(linetext));
  1339. X            
  1340. X            lastline = nextline;
  1341. X        }
  1342. X    }
  1343. X}
  1344. X
  1345. Xvoid
  1346. XO_output(start,flags)
  1347. XE_edit start;
  1348. Xint flags;
  1349. X{
  1350. X    int type = _O_TYPE_E;    /* initialize to error state
  1351. X                ** this is to make sure that type is set
  1352. X                ** somewhere
  1353. X                */
  1354. X    int t_beg1, t_beg2, t_end1, t_end2; /* token numbers */
  1355. X    int first1, last1, first2, last2;
  1356. X
  1357. X    E_edit ep, behind, ahead, a, b;
  1358. X
  1359. X    /*
  1360. X    **    reverse the list of edits
  1361. X    */
  1362. X    ahead = start;
  1363. X    ep = E_NULL;
  1364. X    while (ahead != E_NULL) {
  1365. X        /*
  1366. X        **    set token numbers intentionally out of range
  1367. X        **        as boilerplate
  1368. X        */
  1369. X        t_beg1 = t_beg2 = t_end1 = t_end2 = -1;
  1370. X        /*
  1371. X        **    edit script is 1 origin, all of
  1372. X        **     our routines are zero origin
  1373. X        */
  1374. X        E_setl1(ahead,(E_getl1(ahead))-1);
  1375. X        E_setl2(ahead,(E_getl2(ahead))-1);
  1376. X
  1377. X        behind = ep;
  1378. X        ep = ahead;
  1379. X        ahead = E_getnext(ahead);
  1380. X        E_setnext(ep,behind);
  1381. X    }
  1382. X
  1383. X    /*
  1384. X    **    now run down the list and collect the following information
  1385. X    **    type of change (_O_APP, _O_DEL or _O_CHA)
  1386. X    **    start and length for each file
  1387. X    */
  1388. X    while (ep != E_NULL)
  1389. X    {
  1390. X        b = ep;
  1391. X        /*
  1392. X        **    operation always start here
  1393. X        */
  1394. X        t_beg1 = E_getl1(ep);
  1395. X        /*
  1396. X        **    any deletions will appear before any insertions,
  1397. X        **    so, if the first edit is an E_INSERT, then this
  1398. X        **    this is an _O_APP
  1399. X        */
  1400. X        if (E_getop(ep) == E_INSERT)
  1401. X            type = _O_APP;
  1402. X        else {
  1403. X            /*
  1404. X            **    run down the list looking for the edit
  1405. X            **    that is not part of the current deletion
  1406. X            */    
  1407. X            do {
  1408. X                a = b;
  1409. X                b = E_getnext(b);
  1410. X            } while ((b != E_NULL) &&
  1411. X                 (E_getop(b) == E_DELETE) &&
  1412. X                 ((E_getl1(b)) == ((E_getl1(a))+1)));
  1413. X            /*
  1414. X            **    if we have an insertion at the same place
  1415. X            **    as the deletion we just scanned, then
  1416. X            **    this is a change
  1417. X            */
  1418. X            if ((b != E_NULL) &&
  1419. X                ((E_getop(b)) == E_INSERT) &&
  1420. X                ((E_getl1(b))==(E_getl1(a))))
  1421. X            {
  1422. X                type = _O_CHA;
  1423. X            }
  1424. X            else
  1425. X            {
  1426. X                type = _O_DEL;
  1427. X            }
  1428. X            /*
  1429. X            **    set up start and length information for
  1430. X            **    first file
  1431. X            */
  1432. X            t_end1 = E_getl1(a);
  1433. X            /*
  1434. X            **    move pointer to beginning of insertion
  1435. X            */
  1436. X            ep = b;
  1437. X            /*
  1438. X            **    if we are showing only a deletion,
  1439. X            **    then we're all done, so skip ahead
  1440. X            */ 
  1441. X            if (_O_DEL == type)
  1442. X            {
  1443. X                t_beg2 = E_getl2(a);
  1444. X                t_end2 = -1;    /* dummy number, won't
  1445. X                            ever be printed */
  1446. X                           
  1447. X                goto skipit;
  1448. X            }
  1449. X        }
  1450. X        t_beg2 = E_getl2(ep);
  1451. X        t_end2 = t_beg2-1;
  1452. X        /*
  1453. X        **    now run down the list lookingfor the
  1454. X        **    end of this insertion and keep count
  1455. X        **    of the number of times we step along
  1456. X        */
  1457. X        do {
  1458. X            t_end2++;
  1459. X            ep = E_getnext(ep);
  1460. X        } while ((ep != E_NULL) && ((E_getop(ep)) == E_INSERT) &&
  1461. X                    ((E_getl1(ep)) == (E_getl1(b))));
  1462. X
  1463. Xskipit:;
  1464. X        if (flags & U_TOKENS)
  1465. X        {
  1466. X            /*
  1467. X            **    if we are dealing with tokens individually,
  1468. X            **    then just print then set printing so
  1469. X            */
  1470. X                first1 = t_beg1;
  1471. X                last1 = t_end1;
  1472. X                first2 = t_beg2;
  1473. X                last2 = t_end2;
  1474. X        }
  1475. X        else
  1476. X        {
  1477. X            /*
  1478. X            **    we are printing differences in terms of lines
  1479. X            **    so find the beginning and ending lines of the
  1480. X            **    changes and print header in those terms
  1481. X            */
  1482. X            if ( t_beg1 >= 0)
  1483. X                first1 = K_getline(K_get_token(0,t_beg1));
  1484. X            else
  1485. X                first1 = t_beg1;
  1486. X
  1487. X            if ( t_end1 >= 0)
  1488. X                last1 = K_getline(K_get_token(0,t_end1));
  1489. X            else
  1490. X                last1 = t_end1;
  1491. X
  1492. X            if ( t_beg2 >= 0)
  1493. X                first2 = K_getline(K_get_token(1,t_beg2));
  1494. X            else
  1495. X                first2 = t_beg2;
  1496. X
  1497. X            if ( t_end2 >= 0)
  1498. X                last2 = K_getline(K_get_token(1,t_end2));
  1499. X            else
  1500. X                last2 = t_end2;
  1501. X
  1502. X        }
  1503. X        /*
  1504. X        **    print the header for this difference
  1505. X        */
  1506. X        (void) printf("%d",_O_con_line(first1,flags,0));
  1507. X        switch (type)
  1508. X        {
  1509. X        case _O_APP :
  1510. X            (void) printf("a%d",_O_con_line(first2,flags,1));
  1511. X            if (last2 > first2)
  1512. X            {
  1513. X                (void) printf(",%d",_O_con_line(last2,flags,1));
  1514. X            }
  1515. X            (void) printf("\n");
  1516. X            break;
  1517. X        case _O_DEL :
  1518. X            if (last1 > first1)
  1519. X            {
  1520. X                (void) printf(",%d",_O_con_line(last1,flags,0));
  1521. X            }
  1522. X            (void) printf("d%d\n",_O_con_line(first2,flags,1));
  1523. X            break;
  1524. X        case _O_CHA :
  1525. X            if (last1 > first1)
  1526. X            {
  1527. X                (void) printf(",%d",_O_con_line(last1,flags,0));
  1528. X            }
  1529. X            (void) printf("c%d",_O_con_line(first2,flags,1));
  1530. X            if (last2 > first2)
  1531. X            {
  1532. X                (void) printf(",%d",_O_con_line(last2,flags,1));
  1533. X            }
  1534. X            (void) printf("\n");
  1535. X            break;
  1536. X        default:
  1537. X            Z_fatal("type in O_output wasn't set\n");
  1538. X        }
  1539. X        if (_O_DEL == type || _O_CHA == type)
  1540. X        {
  1541. X            if (flags & U_TOKENS)
  1542. X            {
  1543. X                int cnt;
  1544. X                for(cnt=first1;cnt <= last1; cnt++)
  1545. X                {
  1546. X        (void) printf("< %s",
  1547. X                            _O_get_text(0,cnt,flags));
  1548. X                }
  1549. X            }
  1550. X            else
  1551. X            {    
  1552. X                _O_do_lines(t_beg1,t_end1,0);
  1553. X            }
  1554. X        }
  1555. X        if (_O_CHA == type)
  1556. X        {
  1557. X            (void) printf("---\n");
  1558. X        }
  1559. X        if (_O_APP == type || _O_CHA == type)
  1560. X        {
  1561. X            if (flags & U_TOKENS)
  1562. X            {
  1563. X                int cnt;
  1564. X                for(cnt=first2;cnt <= last2; cnt++)
  1565. X                {
  1566. X                    (void) printf("> %s",
  1567. X                        _O_get_text(1,cnt,flags));
  1568. X                }
  1569. X            }
  1570. X            else
  1571. X            {
  1572. X                _O_do_lines(t_beg2,t_end2,1);
  1573. X            }
  1574. X        }
  1575. X    }
  1576. X    O_cleanup();
  1577. X    return;
  1578. X}
  1579. END_OF_FILE
  1580. if test 10536 -ne `wc -c <'output.c'`; then
  1581.     echo shar: \"'output.c'\" unpacked with wrong size!
  1582. fi
  1583. # end of 'output.c'
  1584. fi
  1585. if test -f 'spiff.c' -a "${1}" != "-c" ; then 
  1586.   echo shar: Will not clobber existing file \"'spiff.c'\"
  1587. else
  1588. echo shar: Extracting \"'spiff.c'\" \(6721 characters\)
  1589. sed "s/^X//" >'spiff.c' <<'END_OF_FILE'
  1590. X/*                        Copyright (c) 1988 Bellcore
  1591. X**                            All Rights Reserved
  1592. X**       Permission is granted to copy or use this program, EXCEPT that it
  1593. X**       may not be sold for profit, the copyright notice must be reproduced
  1594. X**       on copies, and credit should be given to Bellcore where it is due.
  1595. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  1596. X*/
  1597. X
  1598. X
  1599. X#ifndef lint
  1600. Xstatic char rcsid[]= "$Header: spiff.c,v 1.1 88/09/15 11:33:51 daniel Rel $";
  1601. X#endif
  1602. X
  1603. X
  1604. X#include <stdio.h>
  1605. X#include "misc.h"
  1606. X#include "flagdefs.h"
  1607. X#include "parse.h"
  1608. X#include "edit.h"
  1609. X#include "line.h"
  1610. X#include "token.h"
  1611. X#include "tol.h"
  1612. X#include "command.h"
  1613. X#include "compare.h"
  1614. X#include "exact.h"
  1615. X#include "miller.h"
  1616. X#include "visual.h"
  1617. X#include "output.h"
  1618. X
  1619. Xextern void _Y_doargs();
  1620. X
  1621. Xstatic int _Y_eflag = 0;    /* use exact match algorithm */
  1622. Xstatic int _Y_vflag = 0;    /* use visual mode */
  1623. X
  1624. X/*
  1625. X**    this is the set of flags that gets used throughout the top module
  1626. X**    as well as being used to communicate between modules.
  1627. X*/
  1628. Xstatic int _Y_flags;
  1629. X
  1630. Xmain(argc,argv)
  1631. Xint argc;
  1632. Xchar *argv[];
  1633. X{
  1634. X    E_edit edit_end;
  1635. X    char *filename[2];
  1636. X
  1637. X    int max_d;     /* max number of differences allowed */
  1638. X    int i;        /* loop counter */
  1639. X
  1640. X    /*
  1641. X    **    parse the command line
  1642. X    */
  1643. X    _Y_doargs(argc,argv,&(filename[0]),&(filename[1]),&max_d);
  1644. X
  1645. X    /*
  1646. X    **    initialize the default tolerance if it
  1647. X    **        hasn't been set already.
  1648. X    */
  1649. X    T_initdefault();
  1650. X
  1651. X    /*
  1652. X    **    read and then parse the files
  1653. X    */
  1654. X
  1655. X    /*
  1656. X    **    L_initfile return a code that indicates if the
  1657. X    **    entire file was read or not
  1658. X    **
  1659. X    **    P_fileparse also knows how to start at someplace other
  1660. X    **        than the first line of file
  1661. X    **
  1662. X    **    Taken together, this is enough to do step our way
  1663. X    **        through the file using an exact match algorithm.
  1664. X    **
  1665. X    **    Oh well, someday . . .
  1666. X    */
  1667. X    for(i=0;i<=1;i++)
  1668. X    {
  1669. X        /*
  1670. X        **    read the file into core
  1671. X        */
  1672. X        (void) L_init_file(i,filename[i]);
  1673. X        K_settmax(i,0);        /* start tokens at 0 */
  1674. X        /*
  1675. X        **    and parse the files into tokens
  1676. X        */
  1677. X        P_file_parse(i,0,L_getrlmax(i),_Y_flags);
  1678. X    }
  1679. X
  1680. X    if (_Y_vflag)
  1681. X    {
  1682. X        return(V_visual(_Y_flags));
  1683. X    }
  1684. X
  1685. X    /*
  1686. X    **    if max_d was not set on the command line
  1687. X    **        set it to be as large as is possible
  1688. X    **        since the most changes possible would
  1689. X    **        be to delete all the tokens in the
  1690. X    **        first file and add all the tokens from
  1691. X    **        the second, the max possible is the
  1692. X    **        sum of the number of tokens in the
  1693. X    **        two files.
  1694. X    */
  1695. X    if (-1 == max_d)
  1696. X        max_d = K_gettmax(0) + K_gettmax(1);
  1697. X
  1698. X    if (_Y_eflag)
  1699. X    {
  1700. X        edit_end = Q_do_exact(K_gettmax(0),K_gettmax(1),
  1701. X                    max_d,_Y_flags);
  1702. X    }
  1703. X    else
  1704. X    {
  1705. X        edit_end = G_do_miller(K_gettmax(0), K_gettmax(1),
  1706. X                     max_d,_Y_flags);
  1707. X    }
  1708. X
  1709. X    if (E_NULL != edit_end)
  1710. X    {
  1711. X        O_output(edit_end,_Y_flags);
  1712. X        return(1);
  1713. X    }
  1714. X    return(0);
  1715. X}
  1716. X
  1717. X/*
  1718. X**    break a string into individual lines and feed
  1719. X**        them to the command module
  1720. X*/
  1721. Xstatic void
  1722. X_Y_cmdlines(from)
  1723. Xchar *from;
  1724. X{
  1725. X    char buf[Z_LINELEN]; 
  1726. X    char *to;
  1727. X    while ('\0' != *from)
  1728. X    {
  1729. X        /*
  1730. X        **    copy line into buf
  1731. X        */
  1732. X        to = buf;
  1733. X        while (('\0' != *from) && ('\n' != *from))
  1734. X        {
  1735. X            *to++ = *from++;
  1736. X        }
  1737. X        *to = '\0';    /* terminate the line */
  1738. X
  1739. X        /*
  1740. X        **    hand the line to the command module
  1741. X        */
  1742. X        C_addcmd(buf);
  1743. X        /*
  1744. X        **    skip the newline
  1745. X        */
  1746. X        if ('\n' == *from)
  1747. X        {
  1748. X            from++;
  1749. X        }
  1750. X    }
  1751. X}
  1752. X
  1753. X/*
  1754. X**    this useful macro handle arguements that are adjacent
  1755. X**    to a flag or in the following word e.g --
  1756. X**
  1757. X**        -a XXX 
  1758. X**    and
  1759. X**        -aXXX 
  1760. X**
  1761. X**    both work when SETPTR is used. 
  1762. X*/
  1763. X#define SETPTR    {if(strlen(argv[1]) == 2) {argv++;argc--;ptr=argv[1];}else ptr=(&argv[1][2]);}
  1764. X
  1765. Xstatic void
  1766. X_Y_doargs(argc,argv,file1,file2,max_d)
  1767. Xint argc;
  1768. Xchar *argv[];
  1769. Xchar **file1,**file2;
  1770. Xint *max_d;
  1771. X{
  1772. X    char *ptr;
  1773. X
  1774. X    /*
  1775. X    **    mark maximum number of tokens as being unset
  1776. X    */
  1777. X    *max_d = -1;
  1778. X
  1779. X    while (argc > 1 && argv[1][0] == '-')
  1780. X    {
  1781. X        switch (argv[1][1])
  1782. X        {
  1783. X            case 't':
  1784. X                _Y_flags |= U_TOKENS;
  1785. X                break;
  1786. X            case 'w':
  1787. X                _Y_flags |= U_INCLUDE_WS;
  1788. X                break;
  1789. X
  1790. X            case 'b':
  1791. X                _Y_flags |= U_BYTE_COMPARE;
  1792. X                break;
  1793. X
  1794. X            case 'c':
  1795. X                _Y_flags |= U_NO_CASE;
  1796. X                break;
  1797. X            case 'd' :
  1798. X                _Y_flags |= U_NEED_DECIMAL;
  1799. X                break;
  1800. X            case 'm' :
  1801. X                _Y_flags |= U_INC_SIGN;
  1802. X                break;
  1803. X            case 'a':
  1804. X                SETPTR;
  1805. X                T_defatol(ptr);
  1806. X                break;
  1807. X            case 'r':
  1808. X                SETPTR;
  1809. X                T_defrtol(ptr);
  1810. X                break;
  1811. X            case 'i':
  1812. X                T_defitol();
  1813. X                break;
  1814. X            case 'e' :
  1815. X                _Y_eflag = 1;
  1816. X                break;
  1817. X            case 'v' :
  1818. X                _Y_vflag = 1;
  1819. X                break;
  1820. X            case 'q' :
  1821. X                Z_setquiet();
  1822. X                break;
  1823. X            case 's' :
  1824. X                SETPTR;
  1825. X                _Y_cmdlines(ptr);
  1826. X                break;
  1827. X            case 'f' :
  1828. X            {
  1829. X                extern FILE *fopen();
  1830. X                char buf[Z_LINELEN];
  1831. X                FILE *cmdfile;
  1832. X                SETPTR;
  1833. X                if ((FILE*) NULL ==
  1834. X                    (cmdfile = fopen(ptr,"r")))
  1835. X                {
  1836. X                    Z_fatal("can't open command file\n");
  1837. X                }
  1838. X                while ((char*) NULL !=
  1839. X                    (char*) fgets(buf,Z_LINELEN,cmdfile))
  1840. X                {
  1841. X                    C_addcmd(buf);
  1842. X                }
  1843. X                (void) fclose(cmdfile);
  1844. X                break;
  1845. X            }
  1846. X            /*
  1847. X            **    useful commands for
  1848. X            **     the C programming language
  1849. X            */
  1850. X            case 'C' :
  1851. X                C_addcmd("literal  \"   \"    \\ ");
  1852. X                C_addcmd("comment  /*  */     ");
  1853. X                C_addcmd("literal  &&         ");
  1854. X                C_addcmd("literal  ||         ");
  1855. X                C_addcmd("literal  <=         ");
  1856. X                C_addcmd("literal  >=         ");
  1857. X                C_addcmd("literal  !=         ");
  1858. X                C_addcmd("literal  ==         ");
  1859. X                C_addcmd("literal  --         ");
  1860. X                C_addcmd("literal  ++         ");
  1861. X                C_addcmd("literal  <<         ");
  1862. X                C_addcmd("literal  >>         ");
  1863. X                C_addcmd("literal  ->         ");
  1864. X                C_addcmd("addalpha _         ");
  1865. X                C_addcmd("tol      a0          ");
  1866. X                break;
  1867. X            /*
  1868. X            **    useful commands for
  1869. X            **     the Bourne shell programming language
  1870. X            */
  1871. X            case 'S' :
  1872. X                C_addcmd("literal  '    '    \\    ");
  1873. X                C_addcmd("comment  #    $    ");
  1874. X                C_addcmd("tol      a0         ");
  1875. X                break;
  1876. X            /*
  1877. X            **    useful commands for
  1878. X            **     the Fortran programming language
  1879. X            */
  1880. X            case 'F' :
  1881. X                C_addcmd("literal  '    '     ' ");
  1882. X                C_addcmd("comment  ^C   $    ");
  1883. X                C_addcmd("tol      a0         ");
  1884. X                break;
  1885. X            /*
  1886. X            **    useful commands for
  1887. X            **     the Lisp programming language
  1888. X            */
  1889. X            case 'L' :
  1890. X                C_addcmd("literal  \"     \"    ");
  1891. X                C_addcmd("comment  ;     $    ");
  1892. X                C_addcmd("tol      a0         ");
  1893. X                break;
  1894. X            /*
  1895. X            **    useful commands for
  1896. X            **     the Modula-2 programming language
  1897. X            */
  1898. X            case 'M' :
  1899. X                C_addcmd("literal '     '    ");
  1900. X                C_addcmd("literal \"    \"    ");
  1901. X                C_addcmd("comment (*    *)    ");
  1902. X                C_addcmd("literal :=        ");
  1903. X                C_addcmd("literal <>        ");
  1904. X                C_addcmd("literal <=        ");
  1905. X                C_addcmd("literal >=        ");
  1906. X                C_addcmd("tol      a0         ");
  1907. X                break;
  1908. X            case '0':
  1909. X            case '1':
  1910. X            case '2':
  1911. X            case '3':
  1912. X            case '4':
  1913. X            case '5':
  1914. X            case '6':
  1915. X            case '7':
  1916. X            case '8':
  1917. X            case '9':
  1918. X                *max_d = atoi(&argv[1][1]);
  1919. X                break;
  1920. X            default:
  1921. X                Z_fatal("don't understand arguments\n");
  1922. X        }
  1923. X        ++argv;
  1924. X        --argc;
  1925. X    }
  1926. X    if (argc != 3)
  1927. X        Z_fatal ("spiff requires two file names.\n");
  1928. X    *file1 = argv[1];
  1929. X    *file2 = argv[2];
  1930. X}
  1931. END_OF_FILE
  1932. if test 6721 -ne `wc -c <'spiff.c'`; then
  1933.     echo shar: \"'spiff.c'\" unpacked with wrong size!
  1934. fi
  1935. # end of 'spiff.c'
  1936. fi
  1937. if test -f 'tol.c' -a "${1}" != "-c" ; then 
  1938.   echo shar: Will not clobber existing file \"'tol.c'\"
  1939. else
  1940. echo shar: Extracting \"'tol.c'\" \(5820 characters\)
  1941. sed "s/^X//" >'tol.c' <<'END_OF_FILE'
  1942. X/*                        Copyright (c) 1988 Bellcore
  1943. X**                            All Rights Reserved
  1944. X**       Permission is granted to copy or use this program, EXCEPT that it
  1945. X**       may not be sold for profit, the copyright notice must be reproduced
  1946. X**       on copies, and credit should be given to Bellcore where it is due.
  1947. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  1948. X*/
  1949. X
  1950. X
  1951. X#ifndef lint
  1952. Xstatic char rcsid[]= "$Header: tol.c,v 1.1 88/09/15 11:33:59 daniel Rel $";
  1953. X#endif
  1954. X
  1955. X#include "misc.h"
  1956. X#include "float.h"
  1957. X#include "tol.h"
  1958. X#include "token.h"
  1959. X
  1960. X/*
  1961. X**    storage for the default tolerances
  1962. X*/
  1963. XT_tol _T_gtol = _T_null;
  1964. X
  1965. X/*
  1966. X**    tolerances that can be set in the command script and attached to floating
  1967. X**        point numbers at parse time
  1968. X*/
  1969. Xstatic T_tol _T_tols[_T_TOLMAX];
  1970. X
  1971. X/*
  1972. X**    initialize the global tolerance
  1973. X**    should be called only once at the beginning of the program
  1974. X*/
  1975. Xvoid
  1976. XT_initdefault()
  1977. X{
  1978. X    static int called_before = 0;
  1979. X
  1980. X    if (called_before)
  1981. X    {
  1982. X        Z_fatal("T_initdefault called more than once\n");
  1983. X    }
  1984. X
  1985. X    /*
  1986. X    **    if the default tolerance was set somewhere else
  1987. X    **    don't set it here
  1988. X    */
  1989. X    if (T_isnull(_T_gtol))
  1990. X    {
  1991. X        T_defatol(_T_ADEF);
  1992. X        T_defrtol(_T_RDEF);
  1993. X    }
  1994. X    called_before = 1;
  1995. X}
  1996. X
  1997. Xstatic void
  1998. X_T_tolclear(addr)
  1999. XT_tol *addr;
  2000. X{
  2001. X    *addr = _T_null;
  2002. X}
  2003. X
  2004. X/*
  2005. X**    clear the parse time tolerances
  2006. X*/
  2007. Xvoid
  2008. XT_clear_tols()
  2009. X{
  2010. X    int i;
  2011. X    for(i=0;i<_T_TOLMAX;i++)
  2012. X    {
  2013. X        _T_tolclear(&_T_tols[i]);
  2014. X    }
  2015. X}
  2016. X
  2017. Xstatic void
  2018. X_T_defclear()
  2019. X{
  2020. X    _T_tolclear(&_T_gtol);
  2021. X}
  2022. X
  2023. X/*
  2024. X**    take a series of specifiers and add them to the tolerance
  2025. X*/
  2026. Xstatic void
  2027. X_T_settol(toladdr,str)
  2028. XT_tol *toladdr;
  2029. Xchar *str;
  2030. X{
  2031. X    char typechar;
  2032. X    while ('\0' != *str)
  2033. X    {
  2034. X        /*
  2035. X        **    find the first non-whitespace character
  2036. X        */
  2037. X        S_skipspace(&str);
  2038. X        /*
  2039. X        **    snarf up the type specifier
  2040. X        */
  2041. X        typechar = *str;
  2042. X        /*
  2043. X        **    now skip the first char
  2044. X        */
  2045. X        str++;
  2046. X        /*
  2047. X        **    skip any possibly intervening whitespace
  2048. X        */
  2049. X        S_skipspace(&str);
  2050. X        switch (typechar)
  2051. X        {
  2052. X            case 'a':
  2053. X                _T_addtol(toladdr,T_ABSOLUTE,str);
  2054. X                break;
  2055. X            case 'r':
  2056. X                _T_addtol(toladdr,T_RELATIVE,str);
  2057. X                break;
  2058. X            case 'i':
  2059. X                _T_addtol(toladdr,T_IGNORE,(char*)0);
  2060. X                break;
  2061. X            case 'd':
  2062. X                _T_appendtols(toladdr,_T_gtol);
  2063. X                break;
  2064. X            default:
  2065. X                (void) sprintf(Z_err_buf,
  2066. X                  "don't understand tolerance type '%c'\n",typechar);
  2067. X                Z_fatal(Z_err_buf);
  2068. X        }
  2069. X        /*
  2070. X        **    and skip to next tolerance
  2071. X        */
  2072. X        S_nextword(&str);
  2073. X    }
  2074. X}
  2075. X
  2076. X/*
  2077. X**    set the default tolerance 
  2078. X*/
  2079. Xvoid
  2080. XT_setdef(str)
  2081. Xchar *str;
  2082. X{
  2083. X    _T_defclear();
  2084. X    _T_settol(&_T_gtol,str);
  2085. X}
  2086. X
  2087. X
  2088. Xstatic char*
  2089. X_T_nextspec(ptr)
  2090. Xchar *ptr;
  2091. X{
  2092. X    /*
  2093. X    **    find the end of the current spec
  2094. X    */
  2095. X    for(;(_T_SEPCHAR != *ptr) && ('\0' != *ptr);ptr++)
  2096. X    {
  2097. X    }
  2098. X
  2099. X    /*
  2100. X    **    and step over the seperator if necessary
  2101. X    */
  2102. X    if (_T_SEPCHAR == *ptr)
  2103. X        ptr++;
  2104. X
  2105. X    return(ptr);
  2106. X}
  2107. X
  2108. X/*
  2109. X**    return just the next set of specs
  2110. X**        ie the string up to end of line or
  2111. X**            the first _T_SEPCHAR
  2112. X**    returned string does not include the _T_SEPCHAR
  2113. X*/
  2114. Xstatic char *
  2115. X_T_getspec(from)
  2116. Xchar *from;
  2117. X{
  2118. X    static char retval[Z_LINELEN];
  2119. X    char *ptr = retval;
  2120. X
  2121. X    while((_T_SEPCHAR != *from) && ('\0' != *from))
  2122. X    {
  2123. X        *ptr++ = *from++;
  2124. X    }
  2125. X    *ptr = '\0';    /* terminate the line */
  2126. X    return(retval);
  2127. X}
  2128. X
  2129. X/*
  2130. X**    parse a series of _T_SEPCHAR separated tolerance specifications
  2131. X*/
  2132. Xvoid
  2133. XT_tolline(str)
  2134. Xchar *str;
  2135. X{
  2136. X    int nexttol;
  2137. X
  2138. X    T_clear_tols();
  2139. X
  2140. X    for(nexttol=0;'\0' != *str;nexttol++,str = _T_nextspec(str))
  2141. X    {
  2142. X        /*
  2143. X        **    make sure we haven't run off the end
  2144. X        */
  2145. X        if (nexttol >= _T_TOLMAX)
  2146. X        {
  2147. X            Z_fatal("too many tolerances per line");
  2148. X        }
  2149. X
  2150. X        /*
  2151. X        **    and set the tolerance
  2152. X        */
  2153. X        _T_settol(&_T_tols[nexttol],_T_getspec(str));
  2154. X    }
  2155. X}
  2156. X
  2157. XT_moretols(next_tol)
  2158. X{
  2159. X    return((next_tol >= 0) &&
  2160. X        (_T_TOLMAX-1 > next_tol) &&
  2161. X        (!T_isnull( _T_tols[next_tol+1])));
  2162. X}
  2163. X
  2164. XT_tol
  2165. XT_gettol(index)
  2166. Xint index;
  2167. X{
  2168. X    return(_T_tols[index]);
  2169. X}
  2170. X
  2171. X/*
  2172. X**    chose which tolerance to use
  2173. X**         precidence is
  2174. X**            first tolerance
  2175. X**            second tolerance
  2176. X**            default tolerance
  2177. X*/
  2178. XT_tol
  2179. XT_picktol(p1,p2)
  2180. XT_tol p1, p2;
  2181. X{
  2182. X    if (!(T_isnull(p1)))
  2183. X        return(p1);
  2184. X
  2185. X    if (!(T_isnull(p2)))
  2186. X        return(p2);
  2187. X
  2188. X    return(_T_gtol);
  2189. X}
  2190. X
  2191. Xvoid
  2192. X_T_appendtols(to,from)
  2193. XT_tol *to,from;
  2194. X{
  2195. X
  2196. X    T_tol last;
  2197. X
  2198. X    /*
  2199. X    **    are there any elements on the list yet
  2200. X    */
  2201. X    if (T_isnull(*to))
  2202. X    {
  2203. X        /*
  2204. X        **    it's a null list, so allocat space for the
  2205. X        **        first element and set pointer to it.
  2206. X        */
  2207. X
  2208. X        *to = from;
  2209. X    }
  2210. X    else
  2211. X    {
  2212. X        /*
  2213. X        **    find the last element on the list
  2214. X        */
  2215. X        for(last= *to;!T_isnull(T_getnext(last));last = T_getnext(last))
  2216. X        {
  2217. X        }
  2218. X        /*
  2219. X        **    add an element on the end
  2220. X        */
  2221. X        T_setnext(last,from);
  2222. X    }
  2223. X}
  2224. X
  2225. X/*
  2226. X**    add a tolerance to a list
  2227. X*/
  2228. Xvoid
  2229. X_T_addtol(listptr,type,str)
  2230. XT_tol *listptr;
  2231. Xint type;
  2232. Xchar *str;
  2233. X{
  2234. X    T_tol last;
  2235. X
  2236. X    /*
  2237. X    **    are there any elements on the list yet
  2238. X    */
  2239. X    if (T_isnull(*listptr))
  2240. X    {
  2241. X        /*
  2242. X        **    it's a null list, so allocat space for the
  2243. X        **        first element and set pointer to it.
  2244. X        */
  2245. X
  2246. X        last = *listptr = Z_ALLOC(1,_T_struct);
  2247. X    }
  2248. X    else
  2249. X    {
  2250. X        /*
  2251. X        **    find the last element on the list
  2252. X        */
  2253. X        for(last= *listptr;!T_isnull(T_getnext(last));last = T_getnext(last))
  2254. X        {
  2255. X        }
  2256. X        /*
  2257. X        **    add an element on the end
  2258. X        */
  2259. X        T_setnext(last,Z_ALLOC(1,_T_struct));
  2260. X
  2261. X        /*
  2262. X        **    and point to the new element
  2263. X        */
  2264. X        last = T_getnext(last);
  2265. X    }
  2266. X
  2267. X    T_settype(last,type);
  2268. X    T_setnext(last,_T_null);
  2269. X
  2270. X    /*
  2271. X    **    set the float value only if necessary
  2272. X    */
  2273. X    if (T_IGNORE == type)
  2274. X    {
  2275. X        T_setfloat(last,F_null);
  2276. X    }
  2277. X    else
  2278. X    {
  2279. X        T_setfloat(last,F_atof(str,NO_USE_ALL));
  2280. X
  2281. X        /*
  2282. X        **    test new tolerance for sanity
  2283. X        */
  2284. X        if (F_getsign(T_getfloat(last)))
  2285. X        {
  2286. X            (void) sprintf(Z_err_buf,
  2287. X            "%s : negative tolerances don't make any sense\n",str);
  2288. X            Z_fatal(Z_err_buf);
  2289. X        }
  2290. X        /*
  2291. X        **    check for excessively large relative tolerances
  2292. X        */
  2293. X        if ((T_RELATIVE == type) &&
  2294. X             (F_floatcmp(T_getfloat(last),
  2295. X                     F_atof("2.0",USE_ALL)) > 0))
  2296. X        {
  2297. X            (void) sprintf(Z_err_buf,
  2298. X    "%s : relative tolerances greater than 2 don't make any sense\n",str);
  2299. X            Z_fatal(Z_err_buf);
  2300. X        }
  2301. X    }
  2302. X}
  2303. END_OF_FILE
  2304. if test 5820 -ne `wc -c <'tol.c'`; then
  2305.     echo shar: \"'tol.c'\" unpacked with wrong size!
  2306. fi
  2307. # end of 'tol.c'
  2308. fi
  2309. if test -f 'visual.c' -a "${1}" != "-c" ; then 
  2310.   echo shar: Will not clobber existing file \"'visual.c'\"
  2311. else
  2312. echo shar: Extracting \"'visual.c'\" \(7697 characters\)
  2313. sed "s/^X//" >'visual.c' <<'END_OF_FILE'
  2314. X/*                        Copyright (c) 1988 Bellcore
  2315. X**                            All Rights Reserved
  2316. X**       Permission is granted to copy or use this program, EXCEPT that it
  2317. X**       may not be sold for profit, the copyright notice must be reproduced
  2318. X**       on copies, and credit should be given to Bellcore where it is due.
  2319. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  2320. X*/
  2321. X
  2322. X
  2323. X#ifndef lint
  2324. Xstatic char rcsid[]= "$Header: visual.c,v 1.1 88/09/15 11:34:02 daniel Rel $";
  2325. X#endif
  2326. X
  2327. X#ifdef MGR
  2328. X
  2329. X#include "misc.h"
  2330. X#include "line.h"
  2331. X#include "token.h"
  2332. X#include "/usr/public/pkg/mgr/include/term.h"
  2333. X#include "/usr/public/pkg/mgr/include/restart.h"
  2334. X
  2335. X#define OTHER        0
  2336. X#define ON_DEBUG    1
  2337. X#define OFF_DEBUG    2
  2338. X#define DO_QUIT        3
  2339. X#define DO_PAGE        4
  2340. X#define NEW_PREC    5
  2341. X
  2342. X
  2343. X#define NROW    60
  2344. X#define NCOL    80
  2345. X
  2346. Xint isdiff[MAXTOKENS];    /* flag showing if a token pair was shown different*/
  2347. X
  2348. Xint comwin,wina, winb;    /* location to store window numbers */
  2349. Xint fontx,fonty;    /* size of the font in pixels */
  2350. X
  2351. Xint debug =0;
  2352. X
  2353. X
  2354. Xint firsttoken = 0;    /* index of first token pair being displayed */
  2355. Xint tokencnt;        /* count of the number of token pairs being displayed */
  2356. X
  2357. XV_visual(flags)
  2358. Xint flags;
  2359. X{
  2360. X
  2361. X    int moretodo = 1;    /* flag to clear when we're finished */
  2362. X
  2363. X    messup();
  2364. X
  2365. X    m_selectwin(comwin);
  2366. X    m_setmode(W_ACTIVATE);
  2367. X
  2368. X    showpages(comroutine,flags);
  2369. X
  2370. X    do
  2371. X    {
  2372. X        switch(getinput())
  2373. X        {
  2374. X            case ON_DEBUG:
  2375. X                debug = 0;
  2376. X                break;
  2377. X            case OFF_DEBUG:
  2378. X                debug = 1;
  2379. X                break;
  2380. X            case DO_QUIT:
  2381. X                moretodo = 0;
  2382. X                break;
  2383. X            case DO_PAGE:
  2384. X                if((firsttoken+tokencnt>= K_gettmax(0))||
  2385. X                   (firsttoken+tokencnt>= K_gettmax(1)))
  2386. X                {
  2387. X                    m_selectwin(comwin);
  2388. X                    m_printstr("\007this is the last page\n");
  2389. X                    break;
  2390. X                }
  2391. X                firsttoken += tokencnt;
  2392. X                showpages(comroutine,flags);
  2393. X                break;
  2394. X            case NEW_PREC:
  2395. X                updatepages(comroutine,flags);
  2396. X                break;
  2397. X            case OTHER:
  2398. X                break;
  2399. X            default :
  2400. X                Z_fatal("bad value in main switch");
  2401. X                
  2402. X        }
  2403. X    } while (moretodo);
  2404. X
  2405. X    V_cleanup();
  2406. X    return(0);
  2407. X}
  2408. X
  2409. Xgetinput()
  2410. X{
  2411. X    char ibuf[Z_LINELEN];    /* input buffer */
  2412. X    char *ptr;
  2413. X
  2414. X    m_selectwin(comwin);
  2415. X    m_setmode(W_ACTIVATE);
  2416. X    switch (m_getchar())
  2417. X    {
  2418. X        case 't':
  2419. X            m_gets(ibuf);
  2420. X            /*
  2421. X            **    skip the 'tol'
  2422. X            */
  2423. X            ptr = ibuf;
  2424. X            S_nextword(&ptr);
  2425. X            T_setdef(ptr);
  2426. X            return(NEW_PREC);
  2427. X        case 'q':
  2428. X            return(DO_QUIT);
  2429. X        case 'd':
  2430. X            return(OFF_DEBUG);
  2431. X        case 'D':
  2432. X            return(ON_DEBUG);
  2433. X        case 'm':
  2434. X            return(DO_PAGE);
  2435. X        default:
  2436. X            return(OTHER);
  2437. X    }
  2438. X    
  2439. X}
  2440. X
  2441. Xshowpages(comroutine,flags)
  2442. Xint (*comroutine)();
  2443. Xint flags;
  2444. X{
  2445. X    int i;
  2446. X        m_selectwin(wina);
  2447. X        m_clear();
  2448. X        m_selectwin(winb);
  2449. X        m_clear();
  2450. X        showlines();
  2451. X
  2452. X        for(i=firsttoken;i<tokencnt+firsttoken; i++)
  2453. X        {
  2454. X            isdiff[i] = 0;
  2455. X        }
  2456. X        updatepages(comroutine,flags);
  2457. X}
  2458. X
  2459. Xupdatepages(comroutine,flags)
  2460. Xint (*comroutine)();
  2461. Xint flags;
  2462. X{
  2463. X    int i;
  2464. X
  2465. X    for(i=firsttoken;i<tokencnt+firsttoken; i++)
  2466. X    {
  2467. X        if (isdiff[i])
  2468. X        {
  2469. X
  2470. X            if (0 == X_com(i,i,flags))
  2471. X            {
  2472. X                m_selectwin(wina);
  2473. X                un_highlight(0,K_gettoken(0,i),K_getline(K_gettoken(0,firsttoken)));
  2474. X                m_selectwin(winb);
  2475. X                un_highlight(1,K_gettoken(1,i),K_getline(K_gettoken(1,firsttoken)));
  2476. X                isdiff[i] = 0;
  2477. X            }
  2478. X        }
  2479. X        else
  2480. X        {
  2481. X            if (0 != X_com(i,i,flags))
  2482. X            {
  2483. X                m_selectwin(wina);
  2484. X                highlight(0,K_gettoken(0,i),K_getline(K_gettoken(0,firsttoken)));
  2485. X                m_selectwin(winb);
  2486. X                highlight(1,K_gettoken(1,i),K_getline(K_gettoken(1,firsttoken)));
  2487. X                isdiff[i] = 1;
  2488. X            }
  2489. X        }
  2490. X    }
  2491. X}
  2492. X
  2493. Xun_highlight(file,ptr,firstline)
  2494. Xint file;
  2495. XK_token ptr;
  2496. Xint firstline;
  2497. X{
  2498. X    highlight(file,ptr,firstline);
  2499. X}
  2500. X
  2501. X/*
  2502. X**    argument expressed in terms of token lines
  2503. X*/
  2504. Xhighlight(file,ptr,firstline)
  2505. Xint file;
  2506. XK_token ptr;
  2507. Xint firstline;
  2508. X{
  2509. X    int startx = K_getpos(ptr)*fontx;
  2510. X    int starty = (L_tl2cl(file,K_getline(ptr))-L_tl2cl(file,firstline))*fonty;
  2511. X
  2512. X    int sizex = fontx*strlen(K_gettext(ptr));
  2513. X    int sizey = fonty;
  2514. X    m_bitwrite(startx,starty,sizex,sizey);
  2515. X}
  2516. X
  2517. Xshowlines()
  2518. X{
  2519. X    int Alinecnt = 0;
  2520. X    int Blinecnt = 0;
  2521. X
  2522. X    int Atfirstline = K_getline(K_gettoken(0,firsttoken));
  2523. X    int Btfirstline = K_getline(K_gettoken(1,firsttoken));
  2524. X    int Afirstline =  L_tl2cl(0,K_getline(K_gettoken(0,firsttoken)));
  2525. X    int Bfirstline =  L_tl2cl(1,K_getline(K_gettoken(1,firsttoken)));
  2526. X    int Anexttoken = L_getindex(0,Atfirstline);
  2527. X    int Bnexttoken = L_getindex(1,Btfirstline);
  2528. X    int i;
  2529. X    /*
  2530. X    **    first print the lines on the screen
  2531. X    */
  2532. X    for(i=0;i < NROW;i++)
  2533. X    {
  2534. X        if(Afirstline+i < L_getclmax(0))
  2535. X        {
  2536. X            m_selectwin(wina);
  2537. X            showline(0,Afirstline+i,i);
  2538. X            Alinecnt++;
  2539. X        }
  2540. X
  2541. X        if(Bfirstline+i < L_getclmax(1))
  2542. X        {
  2543. X            m_selectwin(winb);
  2544. X            showline(1,Bfirstline+i,i);
  2545. X            Blinecnt++;
  2546. X        }
  2547. X    }
  2548. X    /*
  2549. X    **    now figure out how many tokens we actually printed
  2550. X    */
  2551. X    for(i=Atfirstline;Anexttoken<K_gettmax(0) && L_tl2cl(0,i) < Afirstline+Alinecnt;i++)
  2552. X    {
  2553. X            Anexttoken += L_getcount(0,i);
  2554. X    }
  2555. X
  2556. X    for(i=Btfirstline;Bnexttoken<K_gettmax(1) && L_tl2cl(1,i) < Bfirstline+Blinecnt;i++)
  2557. X    {
  2558. X            Bnexttoken += L_getcount(1,i);
  2559. X    }
  2560. X    tokencnt = MIN(Anexttoken,Bnexttoken) - firsttoken;
  2561. X
  2562. X    /*
  2563. X    **    draw a line through any tokens that come before the first
  2564. X    **        token that is being compared
  2565. X    */
  2566. X    if (L_getindex(0,Atfirstline) != firsttoken)
  2567. X    {
  2568. X        m_selectwin(wina);
  2569. X        for(i=L_getindex(0,Atfirstline);i<firsttoken;i++)
  2570. X        {
  2571. X            drawline(K_gettoken(0,i),0);
  2572. X        }
  2573. X    }
  2574. X
  2575. X    if (L_getindex(1,Btfirstline) != firsttoken)
  2576. X    {
  2577. X        m_selectwin(winb);
  2578. X
  2579. X        for(i=L_getindex(1,Btfirstline);i<firsttoken;i++)
  2580. X        {
  2581. X            drawline(K_gettoken(1,i),0);
  2582. X        }
  2583. X/*
  2584. Xm_line(Bt[Bindex[Bfirstline]]->pos*fontx,fonty/2,(Bt[firsttoken]->pos*fontx)-2,fonty/2);
  2585. X*/
  2586. X    }
  2587. X
  2588. X    if (Anexttoken > Bnexttoken)
  2589. X    {
  2590. X        m_selectwin(wina);
  2591. X        for(i=Bnexttoken;i<Anexttoken;i++)
  2592. X        {
  2593. X            drawline(K_gettoken(0,i),L_tl2cl(0,K_getline(K_gettoken(0,i)))-Afirstline);
  2594. X        }
  2595. X    }
  2596. X
  2597. X    if (Anexttoken < Bnexttoken)
  2598. X    {
  2599. X        m_selectwin(winb);
  2600. X        for(i=Anexttoken;i<Bnexttoken;i++)
  2601. X        {
  2602. X            drawline(K_gettoken(1,i),L_tl2cl(1,K_getline(K_gettoken(1,i)))-Bfirstline);
  2603. X        }
  2604. X    }
  2605. X
  2606. X}
  2607. X
  2608. X/*
  2609. X**    line is given in conten line
  2610. X*/
  2611. Xdrawline(ptr,line)
  2612. XK_token ptr;
  2613. Xint line;
  2614. X{
  2615. X        m_line(K_getpos(ptr)*fontx,
  2616. X            (line*fonty)+fonty/2,
  2617. X            (K_getpos(ptr)+strlen(K_gettext(ptr)))*fontx,
  2618. X            (line*fonty)+fonty/2);
  2619. X}
  2620. X
  2621. X/*
  2622. X**    takes arguments in terms of content lines
  2623. X*/
  2624. Xshowline(file,index,row)
  2625. Xint file;
  2626. Xint index;
  2627. Xint row;
  2628. X{
  2629. X    static char tmp[Z_LINELEN];
  2630. X    m_move(0,row);
  2631. X    stripnl(tmp,L_getcline(file,index));
  2632. X    m_printstr(tmp);
  2633. X}
  2634. X
  2635. Xstripnl(to,from)
  2636. Xchar *to,*from;
  2637. X{
  2638. X    while ((*from != '\n') && (*from != '\0'))
  2639. X    {
  2640. X        *to++ = *from++;
  2641. X    }
  2642. X    *to = '\0';
  2643. X}
  2644. X
  2645. Xstatic int didscr = 0;
  2646. X
  2647. Xmessup()
  2648. X{
  2649. X    int col, row;
  2650. X    int dum1,dum2,dum3,border;
  2651. X
  2652. X    m_setup(W_FLUSH|W_DEBUG);
  2653. X    m_push(P_EVENT|P_FLAGS|P_POSITION);
  2654. X    get_param(&dum1,&dum2,&dum3,&border);
  2655. X    didscr = 1;
  2656. X    comwin =  m_makewindow(192,50,732,116);
  2657. X    wina = m_makewindow(0,218,570,670);
  2658. X    m_selectwin(wina);
  2659. X    m_font(2);
  2660. X    get_font(&fontx,&fonty);
  2661. X    m_shapewindow(0,218,NCOL*fontx+(2*border),NROW*fonty+(2*border));
  2662. X
  2663. X    get_colrow(&col,&row);
  2664. X    if ((col != NCOL) || (row != NROW))
  2665. X    {
  2666. X        Z_fatal("bad window size");
  2667. X    }
  2668. X    m_func(B_INVERT);
  2669. X    m_setmode(W_ABS);
  2670. X
  2671. X    winb = m_makewindow(580,218,570,670);
  2672. X    m_selectwin(winb);
  2673. X    m_font(2);
  2674. X    get_font(&fontx,&fonty);
  2675. X    m_shapewindow(580,218,NCOL*fontx+(2*border),NROW*fonty+(2*border));
  2676. X
  2677. X    get_colrow(&col,&row);
  2678. X    if ((col != NCOL) || (row != NROW))
  2679. X    {
  2680. X        Z_fatal("bad window size");
  2681. X    }
  2682. X    m_func(B_INVERT);
  2683. X    m_setmode(W_ABS);
  2684. X
  2685. X    m_selectwin(comwin);
  2686. X    m_clear();
  2687. X    m_setmode(W_ABS);
  2688. X    m_setmode(W_ACTIVATE);
  2689. X}
  2690. X
  2691. XV_cleanup()
  2692. X{
  2693. X    if (didscr)
  2694. X    {
  2695. X        m_destroywin(wina);
  2696. X        m_destroywin(winb);
  2697. X        m_destroywin(comwin);
  2698. X        m_popall();
  2699. X        m_setecho();
  2700. X        (void) fclose(m_termin);
  2701. X        (void) fclose(m_termout);
  2702. X    }
  2703. X}
  2704. X
  2705. X#else
  2706. X
  2707. X#include "misc.h"
  2708. X/*
  2709. X**    dummy code for systems that don't have
  2710. X**    the mgr window manager installed
  2711. X*/
  2712. XV_visual(d)
  2713. Xint d;
  2714. X{
  2715. X    Z_fatal("visual mode is not available on this machine\n");
  2716. X    return(-d);    /* boiler plate */
  2717. X}
  2718. X
  2719. Xvoid
  2720. XV_cleanup()
  2721. X{
  2722. X}
  2723. X
  2724. X#endif
  2725. END_OF_FILE
  2726. if test 7697 -ne `wc -c <'visual.c'`; then
  2727.     echo shar: \"'visual.c'\" unpacked with wrong size!
  2728. fi
  2729. # end of 'visual.c'
  2730. fi
  2731. echo shar: End of archive 2 \(of 4\).
  2732. cp /dev/null ark2isdone
  2733. MISSING=""
  2734. for I in 1 2 3 4 ; do
  2735.     if test ! -f ark${I}isdone ; then
  2736.     MISSING="${MISSING} ${I}"
  2737.     fi
  2738. done
  2739. if test "${MISSING}" = "" ; then
  2740.     echo You have unpacked all 4 archives.
  2741.     rm -f ark[1-9]isdone
  2742. else
  2743.     echo You still need to unpack the following archives:
  2744.     echo "        " ${MISSING}
  2745. fi
  2746. ##  End of shell archive.
  2747. exit 0
  2748.